package com.sgcc.activiti.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.activiti.domain.OInterfaceIndex;
import com.sgcc.activiti.service.IOInterfaceIndexService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * 接口维护Controller
 * 
 * @author sgcc
 * @date 2021-04-01
 */
@RestController
@RequestMapping("/oInterfaceIndex")
public class OInterfaceIndexController extends BaseController
{
    @Autowired
    private IOInterfaceIndexService oInterfaceIndexService;

    /**
     * 查询接口维护列表
     */
    //@PreAuthorize(hasPermi = "activiti:index:list")
    @GetMapping("/list")
    public TableDataInfo list(OInterfaceIndex oInterfaceIndex)
    {
        startPage();
        List<OInterfaceIndex> list = oInterfaceIndexService.selectOInterfaceIndexList(oInterfaceIndex);
        return getDataTable(list);
    }

    /**
     * 导出接口维护列表
     */
    //@PreAuthorize(hasPermi = "activiti:index:export")
    @Log(title = "接口维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OInterfaceIndex oInterfaceIndex) throws IOException
    {
        List<OInterfaceIndex> list = oInterfaceIndexService.selectOInterfaceIndexList(oInterfaceIndex);
        ExcelUtil<OInterfaceIndex> util = new ExcelUtil<OInterfaceIndex>(OInterfaceIndex.class);
        util.exportExcel(response, list, "index");
    }

    /**
     * 获取接口维护详细信息
     */
    //@PreAuthorize(hasPermi = "activiti:index:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(oInterfaceIndexService.selectOInterfaceIndexById(id));
    }

    /**
     * 新增接口维护
     */
    //@PreAuthorize(hasPermi = "activiti:index:add")
    @Log(title = "接口维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OInterfaceIndex oInterfaceIndex)
    {
        return toAjax(oInterfaceIndexService.insertOInterfaceIndex(oInterfaceIndex));
    }

    /**
     * 修改接口维护
     */
    //@PreAuthorize(hasPermi = "activiti:index:edit")
    @Log(title = "接口维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OInterfaceIndex oInterfaceIndex)
    {
        return toAjax(oInterfaceIndexService.updateOInterfaceIndex(oInterfaceIndex));
    }

    /**
     * 删除接口维护
     */
    //@PreAuthorize(hasPermi = "activiti:index:remove")
    @Log(title = "接口维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(oInterfaceIndexService.deleteOInterfaceIndexByIds(ids));
    }
}
